import React, { Component } from "react";
import './../taskmanage/Wofuzwderenwu.less'
import servies from "./../../servies";
import { Button, Form,  Select, Table, DatePicker, Space,Input } from "antd";
const { Option } = Select;
const layout = {
  labelCol: {
    span: 8,
  },
  wrapperCol: {
    span: 16,
  },
};
// const { confirm } = Modal;
export default class Shoukuanjilu extends Component {
  constructor(props) {
    super(props);
    this.onChange = this.onChange.bind(this);
    this.state = {
      id: "",
      biaoti: "",
      skleixing: "",
      shoudate: "",
      shoumoney: "",
      ssxmu:"",
      guanlian:"",
      jinji:"",
      chuanguser:"",
      tijiaodate:"",
      chuangjianodate:"",
      data:[], 
    };
    this.del = this.del.bind(this)
  }
  romref = React.createRef();
  formRef = React.createRef();
  
  componentDidMount() {
    //发起请求
   servies.GetShoukuanjilu().then((data)=>{
    console.log(data);
    this.setState({
      data:data
    })
   })
  }
  
  onReset = () => {
    this.formRef.current.resetFields();
  };
  onChange = (e) => {
    e.preventDefault()
    console.log("value", e.target.value);
    let key = e.target.dataset.key;
    this.setState({ [key]: e.target.value });
  };
  // 删除
  del(index){
    const data = [...this.state.data];
    data.splice(index,1)
    this.setState({
      data
    })
  }

  xiangqing(text,record,index){
    console.log(text,record,index)
}
  
  render() {
    const columns = [
      {
        title: "序号",
        dataIndex: "id",
        key: "id",
        width:70,
        align: "center",
      },
      { 
        title: "标题",
        dataIndex: "biaoti",
        key: "biaoti",
        align: "center",
      },
      {
        title: "收款类型",
        dataIndex: "skleixing",
        key: "1",
        align: "center",
      },
      {
        title: "收款时间",
        dataIndex: "shoudate",
        width:120,
        key: "2",
        align: "center",
      },
      {
        title: "收款金额(万)",
        dataIndex: "shoumoney",
        key: "3",
        align: "center",
      },
      {
        title: "所属项目",
        dataIndex: "ssxmu",
        width:120,
        key: "3",
        align: "center",
      },
      {
        title: "关联合同",
        dataIndex: "guanlian",
        width:100,
        key: "4",
        align: "center",
      },
      {
        title: "创建人",
        dataIndex: "chuanguser",
        width:100,
        key: "6",
        align: "center",
      }, {
        title: "创建时间",
        dataIndex: "chuangjianodate",
        width:145,
        key: "7",
        align: "center",
      },
      {
        title: "操作",
        key: "operation",
        fixed: "true",
        render: (text,record,index) =>
        <>
        <span className="actions" onClick={()=>this.del(index)}>删除</span>
        <span className="actions"onClick={()=>this.xiangqing(text,record,index)}>查看详情</span></>,
        align: "center",
      },
    ];
   
    return (
      <>
        <Form
          {...layout} ref={this.formRef} name="control-ref"  onFinish={this.onFinish} >
           <Form.Item name="biaoti" label="标题">
            <Input/>
          </Form.Item>
          <Form.Item name="chuanguser" label="创建人">
            <Input/>
          </Form.Item>
          <Form.Item name="skleixing" label="关联合同">
            <Select allowClear onChange={this.onGenderChange} defaultValue="male" >
              <Option value="male">全部</Option>
              <Option value="female">班组付款</Option>
              <Option value="cailiao">材料采购付款</Option>
              <Option value="hetong">项目合同收款</Option>
              <Option value="linshi">临时付款</Option>
              <Option value="renli">人力工资付款</Option>
            </Select>
          </Form.Item>
          <Form.Item name="guanlian" label="收款类型">
            <Select allowClear onChange={this.onGenderChange} defaultValue="male" >
              <Option value="male">全部</Option>
              <Option value="female">001号合同</Option>
              <Option value="cailiao">002号合同</Option>
              <Option value="hetong">003号合同</Option>
              <Option value="linshi">004号合同</Option>
              <Option value="renli">005号合同</Option>
            </Select>
          </Form.Item>
          <Form.Item name="shoudate" label="收款时间">
            <Space direction="vertical">
              <DatePicker placeholder="" />
            </Space>
          </Form.Item>
          <Form.Item name="chuangjianodate" label="创建时间">
            <Space direction="vertical">
              <DatePicker placeholder="" />
            </Space>
          </Form.Item>
        </Form>
         <div className="ant-btn-block">
            <Button type="primary" htmlType="submit">查询</Button>
            <Button htmlType="button" onClick={this.onReset}>重置</Button>
            </div>
      <Table columns={columns} dataSource={this.state.data} scroll={{x:1280,y:500}} />
      </>
    );
  }
}